package com.lee.transactionaldemo.service;

import com.lee.transactionaldemo.entity.User;
import com.lee.transactionaldemo.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author ：liylw
 * @date ：Created in 2021/4/23 9:35
 */
@Service
public class UserService {
    @Autowired
    private UserMapper userMapper;

    /**
     * 插入A成功
     */
    public void saveUserASuccess(){
        userMapper.insert(User.createA());
    }
    /**
     * 插入A失败
     */
    public void saveUserAFail(){
        userMapper.insert(User.createA());
        throw new RuntimeException("saveUserAFail");
    }
    /**
     * 插入B成功
     */
    public void saveUserBSuccess(){
        userMapper.insert(User.createB());
    }
    /**
     * 插入B失败
     */
    public void saveUserBFail(){
        userMapper.insert(User.createB());
        throw new RuntimeException("saveUserAFail");
    }


}
